#ifndef CONTEXT_H
#define	CONTEXT_H

#include <stdint.h>
#include "../BMC.h"
#include "../HMC.h"
#include "../../6502.h"

#define ECTXT_MASK_PC        0x01
#define ECTXT_MASK_A         0x02
#define ECTXT_MASK_S         0x04
#define ECTXT_MASK_P         0x08
#define ECTXT_MASK_X         0x10
#define ECTXT_MASK_Y         0x20

typedef struct ExeContext{
    uint8_t A, S, P, X, Y;
    
    uint16_t PC;
    
    uint8_t ECXMask;
    
    uint64_t ECXContextHash;
    
    uint64_t ExecutionCount;
    
    BMC* SourceBMC;
    
    HMC* Code;
} ExeContext;

ExeContext* ECX_New(uint8_t Mask);
ExeContext* ECX_NewFromCPUContext(__Context* CPUContext, uint8_t ContextMask);
uint64_t ECX_CalculateHash(ExeContext *EContext);
void     ECX_CalculateAndSetHash(ExeContext *EContext);
char*    ECX_GenerateContextString(ExeContext *EContext);
uint8_t  ECX_GetMaskFromChar(char MaskChar);

#endif	/* CONTEXT_H */

